package com.hz.us.controller;

import com.hz.api.model.dto.StudentDTO;
import com.hz.api.model.request.ApiResponse;
import com.hz.us.service.StudentService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class StudentController {

    @Resource
    StudentService studentService;

    @GetMapping("/student-info")
    public String studentInfo(@RequestParam("studentId") Integer studentId) {
        StudentDTO studentDTO = studentService.getStudentById(studentId);
        return studentDTO == null ? ApiResponse.resNotFound() : ApiResponse.ok(studentDTO);
    }

}
